package cn.supermaster.management.web.rest.system;

import cn.supermaster.management.common.annotation.Log;
import cn.supermaster.management.common.enums.BusinessType;
import cn.supermaster.management.common.page.TableDataInfo;
import cn.supermaster.management.common.response.WebResponse;
import cn.supermaster.management.system.domain.SystemNotice;
import cn.supermaster.management.web.service.system.ISNoticeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.rest.system
 * @ClassName: SystemNoticeRestController
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2021/2/19 19:45
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@RestController
@RequestMapping("/system/notice")
public class SystemNoticeRestController {
    @Autowired
    private ISNoticeService noticeService;

    /**
     * 查询公告列表
     */
    @RequiresPermissions("system:notice:list")
    @PostMapping("/list")
    public TableDataInfo list(SystemNotice notice) {
        return noticeService.queryNoticeList(notice);
    }

    /**
     * 新增保存公告
     */
    @RequiresPermissions("system:notice:add")
    @Log(title = "通知公告", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public WebResponse addSave(SystemNotice notice) {
        return noticeService.addNotice(notice);
    }

    /**
     * 修改保存公告
     */
    @RequiresPermissions("system:notice:edit")
    @Log(title = "通知公告", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public WebResponse editSave(SystemNotice notice) {
        return noticeService.modifyNotice(notice);
    }

    /**
     * 删除公告
     */
    @RequiresPermissions("system:notice:remove")
    @Log(title = "通知公告", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public WebResponse remove(String ids) {
        return noticeService.deleteNotices(ids);
    }
}